<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->increments('id');

            // 从 create_users_table 迁移文件中复制来的
            $table->string('username')->default('')->comment('用户名');
            $table->string('email')->default('')->unique()->comment('邮箱');
            $table->string('password')->default('')->comment('密码');
            $table->rememberToken()->default('')->comment('记住我');

            $table->char('mobile', 11)->default('')->comment('手机号码');
            $table->integer('dept_id')->default(0)->comment('部门id');

            $table->timestamp('last_login_at')->nullable()->comment('上次登录成功的时间');
            $table->string('last_login_ip', 25)->default('')->comment('上次登录IP');
            $table->timestamp('last_login_error_at')->nullable()->comment('上次登录失败的时间');
            $table->integer('login_times')->default(0)->comment('登录成功的次数');
            $table->integer('login_error_times')->default(0)->comment('登录失败的次数');

            $table->tinyInteger('so_status')->default(0)->comment('状态');
            $table->integer('so_order')->default(0)->comment('排序');
            $table->integer('create_admin_id')->default(0)->comment('创建者id');
            $table->timestamp('created_at')->nullable()->useCurrent()->comment('创建时间');
            $table->integer('update_admin_id')->default(0)->comment('更新者id');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->integer('delete_admin_id')->default(0)->comment('删除者id');
            $table->softDeletes('deleted_at')->nullable()->comment('软删除时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');
    }
}
